package com.zzyl.controller.manager;


import com.zzyl.base.PageBean;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.dto.NursingProjectPageQueryDto;
import com.zzyl.entity.NursingProject;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目管理口")
public class NursingProjectController {

    @Autowired
    NursingProjectService nursingProjectService;

    //TODO @ApiOperation("分页条件查询护理项目")
    //@GetMapping
   /* public ResponseResult<PageBean<NursingProjectVo>> nursingprojectquery(NursingProjectPageQueryDto dto) {
        PageBean<NursingProjectVo> vo = nursingProjectService.pagequery(dto);
        return ResponseResult.success(vo);
    }*/
    @GetMapping
    public ResponseResult<PageBean<NursingProjectVo>> nursingprojectquery(NursingProjectPageQueryDto dto) {
        PageBean<NursingProjectVo> pagequery2 = nursingProjectService.pagequery2(dto);
        return ResponseResult.success(pagequery2);
    }

    //TODO @ApiOperation("新增护理项目")
   /* @PostMapping
    public ResponseResult<Void> nursingprojectadd(@RequestBody NursingProjectDto dto) {
        nursingProjectService.add(dto);
        return ResponseResult.success();
    }*/
    @PostMapping
    public ResponseResult<Void> add(@RequestBody NursingProjectDto dto){
        nursingProjectService.add2(dto);
        return ResponseResult.success();
    }

    //TODO @ApiOperation("根据id查询护理项目")
    @GetMapping("/{id}")
    public ResponseResult<NursingProjectVo> selectid(@PathVariable Long id) {
        NursingProjectVo vo = nursingProjectService.selectid(id);
        return ResponseResult.success(vo);
    }

    //TODO @ApiOperation("修改护理项目")
    @PutMapping
    public ResponseResult<Void> update(@RequestBody NursingProjectDto dto) {
        nursingProjectService.update(dto);
        return ResponseResult.success();
    }

    //TODO @ApiOperation("启用、禁用护理项目")
    @PutMapping("/{id}/status/{status}")
    public ResponseResult<Void> status(@PathVariable Long id, @PathVariable Integer status) {
        nursingProjectService.status(id, status);
        return ResponseResult.success();
    }

    //TODO @ApiOperation("删除护理项目")
    @DeleteMapping("/{id}")
    public ResponseResult<Void> deleteid(@PathVariable Long id) {
        nursingProjectService.deleteid(id);
        return ResponseResult.success();

    }


    //TODO @ApiOperation("查询所有护理项目")
    @GetMapping("/all")
    public ResponseResult<List<NursingProject>> selectall() {
        List<NursingProject> nursingProjects = nursingProjectService.selectall();
        return ResponseResult.success(nursingProjects);
    }

}
